import { http } from "../http";

const baseUrl = "/api/vodResource";

export interface VodResourceType {
  id: string;
  areaName: string;
  programName: string;
  signalStatus: number;
  downloadStatus: number;
  previewUrl?: string;
  startTime?: string;
  endTime?: string;
  createTime: string;
}
export interface GetVodResourceListQueryType {
  areaName?: string | null;
  programName?: string | null;
  downloadStatus?: number | null;
  startTime?: string | null;
  endTime?: string | null;
  currentPage?: number | null;
  numPerPage?: number | null;
}

export interface GetVodResourceListResponseType {
  list: VodResourceType[];
  currentPage: number;
  numPerPage: number;
  totalCount: number;
}

export interface AddOrUpdateVodResourceQueryType {
  id?: string;
  areaName: string;
  programName: string;
  signalStatus: number;
  downloadStatus: number;
  previewUrl?: string;
  startTime?: string;
  endTime?: string;
}

export interface GetVodResourceDetailQueryType {
  vodResourceId: string | null;
}

export interface DownloadVodResourceQueryType {
  vodResourceId: string;
  videoUrl: string;
}
export interface DownloadVodResourceResponseType {
  previewUrl: string;
}

// 获取点播资源列表
export const getVodResourceListAPI = (params: GetVodResourceListQueryType) => {
  return http.post(`${baseUrl}/getVodResourceList`, params);
};

// 添加或更新点播资源
export const addOrUpdateVodResourceAPI = (
  params: AddOrUpdateVodResourceQueryType
) => {
  return http.post(`${baseUrl}/addOrUpdateVodResource`, params);
};

// 获取点播资源详情
export const getVodResourceDetailAPI = (
  params: GetVodResourceDetailQueryType
) => {
  return http.post(`${baseUrl}/getVodResourceDetail`, params);
};

// 下载点播资源
export const downloadVodResourceAPI = (
  params: DownloadVodResourceQueryType
) => {
  return http.post(`${baseUrl}/downloadVodResource`, params);
};
